/**
 * 业务接口 -> 基本信息维护
 */
import {
  http,
  baseURL,
  baseURLou,

} from "../conf/index";
import qs from "qs";
import store from "@/store";
import {httpJ} from "@/api/conf/index-json";

// 导入
export const uploadRecipe = (params = {}) => {
  // 文件上传
  return http
    .post(`${baseURLou}/meal/import_excel`, params, {
      headers: { "Content-Type": "multipart/form-data" }
    })
    .then(res => res.data);
};

/*************************************** 就餐管理 *******************************************/

export const syncOrganLocalFood = (params = {}) => {
  return http
    .get(`${baseURLou}/basic/syncOrganLocalFood`, { params })
    .then(res => res.data);
};

export const syncOrganLocalDish = (params = {}) => {
  return http
    .get(`${baseURLou}/basic/syncOrganLocalDish`, { params })
    .then(res => res.data);
};
// 获取就餐配置
export const getDinnerConfig = (params = {}) => {
  return http
    .get(`${baseURLou}/hesuan/FoodSetting/getFoodSetting`, { params })
    .then(res => res.data);
};

// 更新就餐配置
export const updateDinnerConfig = (params = {}) => {
  return httpJ
    .post(`${baseURLou}/hesuan/FoodSetting/updateStandard`, params)
    .then(res => res.data);
};

// 获取交伙数据列表
export const getPartnerInfoList = (params = {}) => {
  return http
    .get(`${baseURLou}/hesuan/Jiaohuo/getJiaoHuoList`, { params })
    .then(res => res.data);
};

// 获取退货数据列表
export const getCancelPartnerInfoList = (params = {}) => {
  return http
    .get(`${baseURLou}/hesuan/Tuihuo/getTuiHuoList`, { params })
    .then(res => res.data);
};

// 获取饭客数据列表
export const getFanKeInfoList = (params = {}) => {
  return http
    .get(`${baseURLou}/hesuan/Fanke/getFanKeList`, { params })
    .then(res => res.data);
};

// 获取交伙类型 || 标准 || 详情
export const getPartnerList = (params = {}) => {
  return http
    .get(`${baseURLou}/hesuan/FoodSetting/getStandardByType`, { params })
    .then(res => res.data);
};

// 新增交伙登记
export const addPartner = (params = {}) => {
  return httpJ.post(`${baseURLou}/hesuan/Jiaohuo/jiaoHuo`, params).then(res => res.data);
};

// 新增退货登记
export const addCancelPartner = (params = {}) => {
  return httpJ.post(`${baseURLou}/hesuan/Tuihuo/tuiHuo`, params).then(res => res.data);
};

// 新增客饭登记
export const addFanKe = (params = {}) => {
  return httpJ.post(`${baseURLou}/hesuan/Fanke/fanKe`, params).then(res => res.data);
};

// 新增单日伙食管理登记
export const addDinnerRegister = (params = {}) => {
  return httpJ.post(`${baseURLou}/hesuan/Huoshi/addHuoshi`, params).then(res => res.data);
};

// 获取单日伙食管理登记详情
export const getDinnerRegisterInfo = (params = {}) => {
  return http
    .get(`${baseURLou}/hesuan/Huoshi/getHuoshiListById`, { params })
    .then(res => res.data);
};

// 获取就餐参数
export const getDinnerParams = (params = {}) => {
  return http
    .get(`${baseURLou}/hesuan/FoodSetting/getParameterSetting`, { params })
    .then(res => res.data);
};

// 获取可报销天数
export const getApplyDays = (params = {}) => {
  return http.get(`${baseURLou}/hesuan/Fanke/getDays`, { params }).then(res => res.data);
};

// 导出交伙记录
export const excelPartnerRecord = () =>
  `${baseURLou}/hesuan/Jiaohuo/getExcel?token=${store ? store.state.vuex_user.token : ""}`;

// 导出退伙记录
export const excelCancelPartnerRecord = () =>
  `${baseURLou}/hesuan/Tuihuo/getExcel?token=${store ? store.state.vuex_user.token : ""}`;

// 导出客饭记录
export const excelApplyRecord = () =>
  `${baseURLou}/hesuan/Fanke/getExcel?token=${store ? store.state.vuex_user.token : ""}`;

// 获取伙食管理登记薄记录
export const getRegisterRecordList = (params = {}) => {
  return http
    .get(`${baseURLou}/hesuan/Huoshi/getHuoshiList`, { params })
    .then(res => res.data);
};

// 获取食谱列表
export const getMealPlanList = (params = {}) => {
  return http
    .post(`${baseURLou}/FoodBookService/selectPresentMealPlan`, qs.stringify(params))
    .then(res => res.data);
};

// 获取实物验收列表
export const getThatDayStockBillCheckList = (params = {}) => {
  return http
    .get(`${baseURLou}/goods/getThatDayStockbillCheck`, { params })
    .then(res => res.data);
};

// 根据日期获取食谱数据
export const getMealMsg = (params = {}) => {baseURL
  return httpJ
    .post(`${baseURLou}/FoodBookService/selectMealPlanDay`, params)
    .then(res => res.data);
};

// 获取单位信息
export const getDepartment = (params = {}) => {
  return http.get(`${baseURLou}/basic/unitInfo`, { params }).then(res => res.data);
};

/*************************************** 标准数据管理 *******************************************/
// 获取标准营养库
export const getNutritionCategoryList = (params = {}) => {
  return http
    .get(`${baseURL}/api/standard/materialQuery`, { params })
    .then(res => res.data);
};

// 获取原料类型(2级联动)
export const getNutritionCategoryType = (params = {}) => {
  return httpJ
    .post(`${baseURL}/api/standard/nutritionCategory`, { params })
    .then(res => res.data);
};

// 获取标准劳动营养强度表
export const getStandardNutritionList = (params = {}) => {
  return httpJ
    .post(`${baseURL}/api/standard/standardNutrition`, { params })
    .then(res => res.data);
};

// 导入标准数据
export const uploadStandard = (params = {}) => {
  // 文件上传
  return http
    .post(`${baseURL}/api/standard/excelImport`, params, {
      headers: { "Content-Type": "multipart/form-data" }
    })
    .then(res => res.data);
};

/*************************************** 图片上传 *******************************************/

// 图片上传oss
export const uploadCropIMG = (params = {}) => {
  return http
    .post(`${baseURLou}/material/import_img`, params, {
      headers: { "Content-Type": "multipart/form-data" }
    })
    .then(res => res.data);
};
// 图片上传oss
export const uploadIMG = (params = {}) => {
  return http
    .post(`${baseURLou}/material/import_img`, params, {
      headers: { "Content-Type": "multipart/form-data" }
    })
    .then(res => res.data);
};
// 删除图片
export const deleteIMG = (params = {}) => {
  return http
    .post(`${baseURLou}/material/delete_img`, qs.stringify(params))
    .then(res => res.data);
};


// 获取生成食谱进度
export const reqPlanProgress = (params = {}) => {
  return http
    .get(`${baseURL}/api/FoodBookService/pre_meal_plan/progress`, { params })
    .then(res => res.data);
};